package com.qf;

import com.qf.bean.Users;
import org.apache.cxf.jaxrs.client.WebClient;

import javax.ws.rs.core.GenericType;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.util.List;

/**
 * 2019/11/29
 * Administrator
 * restfulClient1129
 * 面向对象面向君  不负代码不负卿
 */
public class test {
    public static void main(String[] args) {
        //新增
      /*  Response post = WebClient.create("http://localhost:8080/insertuser")
                .post(new Users(1, "广坤", "男"));//post(传入的对象)
        System.out.println("处理结果:"+post.readEntity(Integer.class));*/
      //修改
     /*   Response post = WebClient.create("http://localhost:8080/updateuser")
                .put(new Users(1, "广坤", "男"));//post(传入的对象)
        System.out.println("处理结果:"+post.readEntity(Integer.class));*/
     //删除
      /*  Response post = WebClient.create("http://localhost:8080//deleteuser/123")
                .delete();//post(传入的对象)
        System.out.println("处理结果:"+post.readEntity(Integer.class));*/
      //单行查询
      /*  Users users = WebClient.create("http://localhost:8080//findbyid/345")
                .accept(MediaType.APPLICATION_JSON)
                .get(Users.class);
        System.out.println("users="+users);*/

      //多行
        List<Users> users = WebClient.create("http://localhost:8080/findall")
                .accept(MediaType.APPLICATION_JSON)
                .get(new GenericType<List<Users>>() {
                });
        for (Users user : users) {
            System.out.println(user);
        }
    }
}
